//
//  CTPDetailTextTableViewCell.m
//  LittleNotes
//
//  Created by 檀志文 on 16/5/21.
//  Copyright © 2016年 ios檀志文. All rights reserved.
//

#import "CTPDetailTextTableViewCell.h"
#import "CTPDrawLine.h"
#import "CTPMessage.h"

@interface CTPDetailTextTableViewCell()

@property (weak, nonatomic) IBOutlet CTPDrawLine *lineView;

// 年月日
@property (weak, nonatomic) IBOutlet UIButton *dateString;

// 时分秒
@property (weak, nonatomic) IBOutlet UILabel *timeString;

// 内容
@property (weak, nonatomic) IBOutlet UILabel *content;

@property (weak, nonatomic) IBOutlet UIImageView *imgView;

@end

@implementation CTPDetailTextTableViewCell


- (void)setMessage:(CTPMessage *)message{
    _message = message;
//  设置时间
    NSString *dateString=[message.created_at substringToIndex:9];
    self.dateString.titleLabel.text = dateString;
    NSRange range = NSMakeRange(11, 8);
    NSString *timeString = [message.created_at substringWithRange:range];
    self.timeString.text = timeString;
//  设置内容
     self.content.text=message.content;
//  设置图片
    
     NSString *imagePath =[sandBoxPath stringByAppendingPathComponent:[NSString stringWithFormat:@"/%@%@",message.pic_urls,@".png"]];
//  从沙盒中获取图片
    self.imgView.image= [[UIImage alloc]initWithContentsOfFile:imagePath];
}

- (void)awakeFromNib {
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

- (void)setHighlighted:(BOOL)highlighted{
    
}

// 设置label居上方显示
- (void)layoutSubviews{
    [super layoutSubviews];
    [self.content sizeToFit];
}

@end
